package com.ymatou.iapi.productprice.service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.business.service.AssertService;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.JsonBeanHelper;
import com.ymttest.utils.MapUtil;

public class GetPriceByProdIdsTradeIsolationCall extends YmatouAutoTestCall implements PriceInterface{

	private static String opurl ="api/Price/GetPriceByProdIdsTradeIsolation";
	
	public GetPriceByProdIdsTradeIsolationCall() {
		super(EnvSetup.getSystemUrl("productprice"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public JSONObject callAndGetReturnData(int buyerId,List<String> productIdList){
		JSONObject requestBean = this.getJsonBean(null);
		
		JsonBeanHelper.updateJsonBean(requestBean, MapUtil.hashMap("BuyerId", buyerId,"ProductIds", new JSONArray(productIdList)));
		
		return callAndGetReturnData(requestBean);
	}

	@Override
	public JSONObject GetReturnDataByBuyerAndId(int buyerId, String id) {
		return callAndGetReturnData(buyerId,Arrays.asList(id));
	}
	
	
	public static void main(String[] args) {
		JSONObject addProductBean = JsonBeanHelper.getJsonBean("com.ymatou.iapi.productprice/GetPriceByProdIdsTradeIsolationCall/test.json");	
		JSONObject addProductBean1 = JsonBeanHelper.getJsonBean("com.ymatou.iapi.productprice/GetPriceByProdIdsTradeIsolationCall/test1.json");	
		Map<String, String> map = new HashMap<>();
		
		map.put( "JsonBeanRequest->UserProductCommonInfo->HsCode","UserProductCommonInfo->HsCode");
		AssertService.assertResultEqual(map, addProductBean, addProductBean1);
	}
}
